import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
//全局引入
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

//按需引入
// import {Carousel,CarouselItem} from "element-ui"
// //注册组件
// Vue.component("el-carousel",Carousel)
// Vue.component("el-carousel-item",CarouselItem)

//路由前置钩子(导航守卫)
router.beforeEach((to, from, next) => {
  let token=localStorage.getItem("stu_token")
  if(token){
    next()
  }else{
    //console.log(to);
    if(to.path=="/login"){
      next()
    }else{
      next({path:"/login"})
    }
  }
})

//引入css
import "@/assets/styles/el-reset.css"
import "@/assets/styles/base.css"
Vue.config.productionTip = false;
 Vue.use(ElementUI);
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
